home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu478.dms / pu478.adf / WBGenie / Source / eg.c next >
C/C++ Source or Header  |  1993-09-12  |  3KB  |  92 lines

  1. /*
  2. **  WBGenie is Copyright 1992 by Steven Velletri.  All Rights Reserved
  3. **
  4. **    Filename:   eg.c
  5. **    Release:    1.0
  6. **    Revision:   0.0
  7. **    Date:       26/07/92
  8. **  Author:     Steven Velletri
  9. **  Purpose:
  10. **      To demostrate how to use the routines in sup_lib.c
  11. **      It updates the tool types:
  12. **          WBG_TOP_EDGE
  13. **          WBG_LEFT_EDGE
  14. **          WBG_WIDTH
  15. **          WBG_HEIGHT
  16. **      with out affecting any others which may exist.
  17. **
  18. **  History:
  19. **
  20. **  Version Author  Date        Reason
  21. **  0.00    SV      10/11/92    Created
  22. **
  23. **  To compile this module I used the SAS/C compiler version 5.10a.
  24. */
  25.  
  26. /* Include other appropriate header files here */
  27.  
  28. #include "sup_lib.h"
  29.  
  30. /* Need to create this */
  31. struct SUPTOOLTYPES wbg_position_tool_types[] =
  32.     {
  33.         { "WBG_TOP_EDGE",       0 },
  34.         { "WBG_LEFT_EDGE",      0 },
  35.         { "WBG_WIDTH",          0 },
  36.         { "WBG_HEIGHT",         0 },
  37.     };
  38.  
  39. BOOL wbg_save_position_tool_types(UBYTE top_edge,
  40.                                   UBYTE left_edge,
  41.                                   UBYTE width,
  42.                                   UBYTE height,
  43.                                   char * icon_name)
  44.     {
  45.     struct DiskObject *dobj;
  46.  
  47.     char ** oldtooltypes, **wbg_tt_buf, **tt_buf;
  48.  
  49.     /* This allocates a 4bytex128byte two dimensional array. */
  50.     wbg_tt_buf = tt_buf = sup_get_buf(4, 128);
  51.  
  52.     if (wbg_tt_buf == NULL)
  53.         return(FALSE);
  54.  
  55.     if (dobj = GetDiskObject(icon_name))
  56.         {
  57.         /* Store the pointer to the original tool types */
  58.         oldtooltypes = dobj->do_ToolTypes;
  59.  
  60.         /* This writes into the two dimensional array created above */
  61.         sprintf(*(tt_buf++), "%s=%d", "WBG_TOP_EDGE",  top_edge);
  62.         sprintf(*(tt_buf++), "%s=%d", "WBG_LEFT_EDGE", left_edge);
  63.         sprintf(*(tt_buf++), "%s=%d", "WBG_WIDTH",     width);
  64.         sprintf(*(tt_buf++), "%s=%d", "WBG_HEIGHT",    height);
  65.  
  66.  
  67.         /* This does all the hard work */
  68.         dobj->do_ToolTypes =
  69.             sup_create_tool_type_array(dobj->do_ToolTypes,
  70.                                        wbg_tt_buf,
  71.                                        wbg_position_tool_types,
  72.                                        4);
  73.  
  74.         if (dobj->do_ToolTypes)
  75.             {
  76.             PutDiskObject(icon_name, dobj);
  77.  
  78.             /* This free must be done */
  79.             sup_free_tool_type_array(dobj->do_ToolTypes);
  80.             }
  81.  
  82.         /* Restore the pointer to the original tool types */
  83.         dobj->do_ToolTypes = oldtooltypes;
  84.         FreeDiskObject(dobj);
  85.         }
  86.  
  87.     /* This free must also be done */
  88.     free(*wbg_tt_buf);
  89.  
  90.     return(TRUE);
  91.     }
  92.